package day09.ExceptionTest;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        //生日 1996-12-5
        try {
            f();
        } catch (ParseException e) {
            //打印完整的异常信息
            System.out.println("日期格式错误");
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println("文件创建失败");
            e.printStackTrace();
        }

    }



    private static void f() throws ParseException, IOException {
        System.out.print("请输入生日：");
        String birthday = new Scanner(System.in).nextLine();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = sdf.parse(birthday);
        //System.out.println(date);
        String path = "~/Desktop/"+date.getTime()+".txt";
        File file = new File(path);
        file.createNewFile();
    }
}
